package com.accp.hotevent.controller;

import com.accp.hotevent.entity.Notice;
import com.accp.hotevent.resp.CommonResp;
import com.accp.hotevent.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/notice")
public class NoticeController {

    @Autowired
    NoticeService noticeService;

    @PostMapping("/add")
    public CommonResp addNotice(@RequestBody Notice notice){
        noticeService.add(notice);
        return CommonResp.success();
    }

    @PutMapping("/update/status")
    public CommonResp updateNotice(@RequestBody Notice notice){
        noticeService.updateStatus(notice);
        return CommonResp.success();
    }

    @GetMapping("/list")
    public CommonResp<List<Notice>> getList(Notice notice){
        List<Notice> notices = noticeService.getList(notice);
        return CommonResp.success(notices);
    }
}
